package org.wx.io.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @description: 初始化模板
 * @author: wangxun
 * @createDate: 2021/2/8
 * @version: 1.0
 */
public class MyInitChannelHandler extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        // 获取管道
        // 每一次请求对应一个channel 一个channel 对应一个pipeline
        ChannelPipeline pipeline = ch.pipeline();
        // HttpServerCodec 编解码器
        pipeline.addLast(new HttpServerCodec())
                .addLast(new WxHttpServerHandler());
    }
}
